Fox's Git Mirrors
🗀 Files • ☸ Work (0) • 🖹 Commits (210) • ⑃ Branches (3) • ⌆ Tags (2) • ♥ Thanks (0)
-─
This is a work in progress and a long overdue attempt to bring all our DSP code together and make it reusable for our future projects.
Before using any of this you should enter the tests directory and execute "make".
This will check if your compiler is able to create binaries that are able to produce correct results when executed.
What we have included so far:
When working with Floating-point arithmetic we soon realize, that addition is not necessarily associative.
For example, whenever we need to add values with an ever decreasing magnitude to a running sum with an ever increasing magnitude, the Kahan summation algorithm comes in handy and helps keeping the error growth small.
Implemented are the follwing Window functions:
• Hann window
• Hamming window
• Lanczos window
• Blackman window
• Gaussian window
• Kaiser window
Implemented are the following finite impulse response filters):
• low-pass filter
• high-pass filter
• band-pass filter
There is also support for cascading, to improve roll-off while a correction factor helps to keep the same cutoff frequency.
Numerically controlled oscillator implemented using a phasor and complex multiplication instead of a lookup table.
When working on a device where multiplication is expensive, the CORDIC comes in handy for computing trigonometric functions.
The following implementations are a good (max 1 LSB error at full range) starting point for your own designs:
• Fixed-point atan2 implementation
The simple moving average gives us the mean of the last N data points.
• SMA1 computes the sum of its internal history buffer at each new input from scratch is and therefore very slow.
• SMA2 updates its internal sum using only the new input and the oldest value in the history buffer. It is therefore the fastest of all and works perfect with integers but suffers from drift when used with floats on sequences having a high dynamic range.
• SMA3 is based on SMA2 but uses the Kahan summation algorithm to reduce drift significantly.
• SMA4 uses a tree and only updates nodes that depend on the new input value and is slower than SMA3 but it has no drift.
The sliding window accelerator uses a tree and only updates nodes that depend on the new input value for the pairwise reduction.
The Bip buffer provides contiguous block access to the last N value stored in a circular buffer.
Example:
T282828
DSP::BipBuffer<TYPE, NUM> history;
*snip*
const TYPE *buf = history(new_value);
*snip*
TYPE newest_value = buf[NUM-1];
TYPE previous_value = buf[NUM-2];
TYPE oldest_value = buf[0];
*snip*
DSP::FastFourierTransform<NUM, TYPE, -1> fwd;
TYPE out[NUM];
fwd(out, history(another_value));
A Digital delay line can be used to align signals with different delays - after filtering, for example.
Some constants we need
• Algorithm for computing uniform and natural cubic splines#Algorithmforcomputingnaturalcubic_splines)
Very useful for data interpolation.
Faster alternative (no Inf/NaN handling) to the std::complex implementation.
Some everyday helpers:
• signum function
• lerp function
• probability density function of the normal distribution
• sinc function
• delta function
When working with Analog-to-digital and Digital-to-analog converters, we often face the ugly truth, that we can't always have a precise Sampling) rate.
But if we can estimate the Sampling frequency offset, we can correct it by Resampling the sampled data.
Interpolation via frequency-domain zero padding.
Sometimes we only need trigonometric functions that stay on the unit circle:
• sine function
• cosine function
Some least mean squares filter implementations:
• Normalized Least Mean Squares
• Normalized Complex Least Mean Squares
Served by rngit 1.4.1 - Generated in 0.05s